package com.star.gateway.biz;

import com.star.common.core.contract.Page;
import com.star.common.core.utils.BeanKit;
import com.star.gateway.contract.param.DemoParam;
import com.star.gateway.contract.query.DemoDetailQuery;
import com.star.gateway.contract.query.DemoPageQuery;
import com.star.gateway.repository.model.DemoBO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 用于gateway领域的查询相关
 *
 * @author zhouhengzhe
 * @version 1.0
 * @date 2023/12/1 17:38
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class DemoQueryService {

    /**
     * 通过ID获取gateway
     *
     * @param gatewayDetailQuery id
     * @return gateway详情
     */
    public DemoBO getDemoById(DemoDetailQuery gatewayDetailQuery) {
        return DemoParam.builder().id(gatewayDetailQuery.getId()).build().one();
    }

    /**
     * 分页查询
     *
     * @param gatewayPageQuery
     * @return
     */
    public Page<DemoBO> pageDemo(DemoPageQuery gatewayPageQuery) {
        return BeanKit.copy(gatewayPageQuery, DemoParam.class).page();
    }

    /**
     * 条件查询
     */
    public void getDemoByCondition() {
        //单个
//        DemoParam.builder().name("").age(10).build().one();
        //多个
//        DemoParam.builder().name("").age(10).build().list();
    }

}
